import request from '@/utils/request'

export default {
  queryRole(tableQuery, tablePage){
    let params={
      page:tablePage.current?tablePage.current:1,
      num:tablePage.size,
      search:tableQuery.rname
    }
    return request({
      url:'/roles',
      method:'get',
      params
    })
  },
  addRole(data){
    return request({
      url:'/roles/store',
      method:'post',
      data
    })
  },
  updateRole(data){
    return request({
      url:'/roles/store',
      method:'post',
      data
    })
  },
  deleteRole(data){
    return request({
      url:'/roles/delete',
      method:'post',
      data
    })
  },
  findRolePerms(rid){
    return request({
      url:`/roles/${rid}/permission`,
      method:'get'
    })
  },
  storeMenuPerms(rid, permissions){
    return request({
      url:`/roles/${rid}/permission`,
      method:'post',
      data:{permissions}
    })
  },
  findRoleApis(rid){
    return request({
      url:`/roles/${rid}/api`,
      method:'get'
    })
  },
  storeApiPerms(rid, apis){
    return request({
      url:`/roles/${rid}/api`,
      method:'post',
      data:{apis}
    })
  },
}
